<?php
	include "inc/userAuth.php";
	include "inc/functions.php";
	
	$gender = "";
	$lastName = "";
	$firstName = "";
	$dd = "";
	$mm = "";
	$yyyy = "";
	$email = "";
	$phoneNumber = "";
	$like = "";
	$not_like = "";
	if(isset($_SESSION['luid'])) {
		include "conn/database.php";
		$sql = "SELECT * FROM `T_PERSON` WHERE PERSON_SID = '".$_SESSION['luid']."' limit 1";
		$res = mysql_query($sql);
		$rows = mysql_num_rows($res);
		if($rows>0){
			$result = mysql_fetch_array($res);
			$gender = $result['GENDER'];
			$lastName = $result['SURNAME'];
			$firstName = $result['FIRST_NAME'];
			
			$date = explode("-",$result['BIRTHDATE']);
			$dd = $date[2];
			$mm = $date[1];
			$yyyy = $date[0];
			
			$email = $result['EMAIL_ADDRESS'];
			$phoneNumber = $result['PHONE_NUMBER'];
			
			$sql2 = "SELECT * FROM `T_WEDDINGS` WHERE WEDDING_ID = '".$_SESSION['wid']."' limit 1";
			$res2 = mysql_query($sql2);
			$rows2 = mysql_num_rows($res2);
			if($rows2>0){
				$result2 = mysql_fetch_array($res2);
				$like = $result2['LEFT_LIKES'];
				$not_like = $result2['LEFT_DISLIKES'];
			} else echo "error! No wedding id selected.";
		} else echo "error! No person id selected.";
	}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="Description" content="Une application mobile unique pour un mariage unique.">
<meta name="Keywords" content="wedding box, mariage, application mobile, appstore, google play, iphone, android, iphone 5, samsung galaxy s3, promesse d'une vie">
<title>Promesse d'une Vie</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<link type="text/css" rel="stylesheet" media="screen" href="css/style.css">
<script type="text/javascript" src="js/jquery-1.7.2.min.js" charset="utf-8"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript" src="js/wedding_form.js" charset="utf-8"></script>
<script type="text/javascript" src="plugin/uploadify/jquery.uploadify.min.js"></script>
<link rel="stylesheet" type="text/css" href="uploadify.css" />
<script type="text/javascript">
    ChangeMedia = function(){
				$("#img_icon_data").val("change");
				$("#imageSlider").hide();
				$("#upload_slider .trashIcon").show();
	}
	
	AnnulerUpload = function(){
				$("#imageSlider").show();
				$("#upload_slider").html('<input name="img_url" id="img_url" type="file" onchange="ChangeMedia();"/><a href="javascript:AnnulerUpload();"><img src="img/trash.gif" title="Annuler" width="16" height="16" class="trashIcon"/></a>');
				$("#img_icon_data").val("no");
	}
</script>
<script type="text/javascript">	

</script>

</head>
<body>	
	<div class="main-content">
		<?php
			include "left-menu.php";
		?>
		
		<div class="right">
			<div id="left-shadow"></div>
			<div class="welcome relative">
				<a id="click-drop"><span>Bonjour <?php echo $_SESSION['fname']?></span></a>
				<a type="button" class="deconnect" value="" name="deconnect" id="bien-deconnect" style="display:none;"/></a>
			</div>
			<div class="top-nav">
				<ul class="tabs">
					<li><a href="addperson-1.php" id="marie-1_on"></a></li>
					<li><span class="bar"></span></li>
					<li><a href="addperson-2.php" id="marie-2">Le marié n&deg;2</a></li>
					<li><span class="bar"></span></li>
					<li><a href="addperson-3.php" id="marie-3">Les mariés</a></li>
				</ul>
			</div>
			<div class="title">
				<h2>Profil du marié n&deg;1</h2>
				<p>Renseignez les informations suivantes :</p>
			</div>

			<form method="post" action="inc/<?php echo(isset($_SESSION['luid'])? 'editperson.php':'addperson.php'); ?>" class="wedding_form relative" id="les-maries-1">
				<div class="showText"></div>
					<input type="hidden" name="addwedding-step" value="step-1">
					<div class="form_text">
						<div class="form_select">
								<label>Civilité<span class="star">*</span></label>
								
								<p class="select_show">Séléctionnez le genre</p>
								<div class="select_options" style="display:none;">
									<a class="select_option" val="MALE">Mr<span class="selectable_opacity"></span></a>
									<a class="select_option" val="FEMALE">Mme<span class="selectable_opacity"></span></a>
								</div>
								<input name="gender" class="select_value" type="hidden" value="<?php echo $gender; ?>"/>
						</div>
					</div>
						
					<div class="form_text">
							<label for="lastName">Nom<span class="star">*</span></label>
						  <input type="text" id="lastName" name="lastName" value="<?php echo $lastName; ?>" />
					</div>
					
					<div class="form_text">
							<label for="firstName">Prénom<span class="star">*</span></label>
							<input type="text" id="firstName" name="firstName" value="<?php echo $firstName; ?>" />
					</div>
					
					<div class="form_text">
						<label>Date de naissance<span class="star">*</span></label>
						<div class="form_select form_select_date">
							<div class="form_select_date">
								<input name="dd" id="dd" class="select_value" type="hidden" value="<?php echo $dd; ?>"/>
								<p class="select_show">Jour</p>
								<div class="select_options" style="display:none;">
									<?php display_select_options_days(); ?>
								</div>
							</div>
						</div>
						<div class="form_select form_select_date">
							<div class="form_select_date">
								<input name="mm" id="mm" class="select_value" type="hidden" value="<?php echo $mm; ?>"/>
								<p class="select_show">Mois</p>
								<div class="select_options" style="display:none;">
									<?php display_select_options_months(); ?>
								</div>
							</div>
						</div>
						<div class="form_select form_select_date">
							<div class="form_select_date">
								<input name="yyyy" id="yyyy" class="select_value" type="hidden" value="<?php echo $yyyy; ?>"/>
								<p class="select_show">Année</p>
								<div class="select_options" style="display:none;">
									<?php display_select_options_years_birth(); ?>
								</div>
							</div>
						</div>
					</div>
					
					<div class="form_text">
						<label for="email">Adresse e-mail<span class="star">*</span></label>
						<input type="email" id="email" name="email" value="<?php echo $email; ?>" <?php echo(isset($_SESSION['luid'])? 'disabled="disabled"':''); ?>/>
					</div>
					
					<div class="form_text">
						<label for="phoneNumber">Téléphone mobile</label>
						<input type="text" id="phoneNumber" name="phoneNumber" maxlength="10" value="<?php echo $phoneNumber; ?>" />
						<p class="below-desc">Permet de vous envoyer les notifications</p>
					</div>
					
					
					<div class="title" style="margin:20px 0;">
						<h2>Dites-nous en un peu plus sur vous...</h2>
					</div>
					
					<div class="form_textaera">
						<label for="like">Ce que vous aimez</label>
						<textarea id="like" name="like" cols="" rows="" placeholder="ex : les voyages, la nature"><?php echo $like; ?></textarea>
						<p class="below-desc">Entre 5 - 40 caractères</p>
					</div>
					
					<div class="form_textaera">
						<label for="not_like">Ce que vous n'aimez pas</label>
						<textarea id="not_like" name="not_like" cols="" rows="" placeholder="ex : les voyages, la nature"><?php echo $not_like; ?></textarea>
						<p class="below-desc">Entre 5 - 40 caractères</p>
					</div>
					
					<div class="upload_photo">
						<p>Photo du marié n&deg;1</p>
						<input name="img_icon_data" id="img_icon_data" type="hidden" value="no" />
							
						<div class="upload_img">
							<?php if($img_url == ''){ ?><img src="images/photo-nofile.png"  /><?php }else{ ?>
							<div id="sliderload_img"><a href=""><img src="<?=  $app_media.$img_url; ?>" /></a></div>
							<?php } ?>
					    </div>
							
					    <div class="upload_image">
							<input name="img_url" id="img_url" type="file" onchange="ChangeMedia()"/>
							<a href="javascript:AnnulerUpload();"><img src="img/trash.gif" title="Annuler" width="16" height="16" class="trashIcon"/></a>
					    </div>	
					</div>
					<input type="submit" value="Enregister" name="submit" class="btn-save button"/>
		    </form>
			
		
		</div>
	</div>
</body>
</html>